package com.lzh.shijicloudstack.controller;

import com.lzh.shijicloudstack.common.R;
import com.lzh.shijicloudstack.common.ResultUtil;
import com.lzh.shijicloudstack.model.dto.category.AddEditCategoryDto;
import com.lzh.shijicloudstack.model.dto.ingredient.AddIngredientDto;
import com.lzh.shijicloudstack.model.dto.ingredient.EditIngredientDto;
import com.lzh.shijicloudstack.model.dto.ingredient.IngredientPageDto;
import com.lzh.shijicloudstack.model.vo.category.CategoryVO;
import com.lzh.shijicloudstack.service.IngredientCategoryService;
import com.lzh.shijicloudstack.service.IngredientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * 食材模块
 *
 * @author luzhiheng
 * @date 2025-01-25
 */
@Api(tags = "食材类别模块")
@RestController
@RequestMapping("/ingredient/category")
public class IngredientCategoryController {

    @Resource
    private IngredientCategoryService ingredientCategoryService;

    @ApiOperation(value = "查询类别列表")
    @PostMapping("/findList")
    public R<List<CategoryVO>> findList() {
        return ResultUtil.success(ingredientCategoryService.findList());
    }

    @ApiOperation(value = "删除")
    @PostMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return ResultUtil.success(ingredientCategoryService.removeById(id));
    }

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    public R<Boolean> add(@RequestBody @Valid AddEditCategoryDto dto) {
        return ResultUtil.success(ingredientCategoryService.add(dto));
    }

    @ApiOperation(value = "修改")
    @PostMapping("/edit")
    public R<Boolean> edit(@RequestBody @Valid AddEditCategoryDto dto) {
        return ResultUtil.success(ingredientCategoryService.edit(dto));
    }

}
